Hibernate Tips: More than 70 solutions to common Hibernate problems by Thorben Janssen

Hibernate Tips: More than 70 solutions to common Hibernate problems by Thorben Janssen

Author:Thorben Janssen [Janssen, Thorben]
Language: eng
Format: azw3
Tags: Cookbook, Tips, Hibernate, Recipes
Published: 2017-03-28T04:00:00+00:00


Learn more

You can also map all entities of the inheritance hierarchy to the same database table. I show you how to do that in How to map an inheritance hierarchy to one table.

How to map an inheritance hierarchy to one table

Problem

My database contains one table, which I want to map to an inheritance hierarchy of entities. How do I define such a mapping?

Solution

JPA and Hibernate support different inheritance strategies which allow you to map the entities to different table structures. The SingleTable strategy is one of them and maps an inheritance hierarchy of entities to a single database table.

Let’s have a look at the entity model before I explain the details of the SingleTable strategy. Authors can write different kinds of Publications, like Books and BlogPosts. The Publication class is the super class of the Book and BlogPost classes.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.